The value function represents the preferences given the risk premium rate = ‘dummy’ and ‘x’ = risk-free rate as input returns a higher value when x -> 1 and dummy > 4. The symmetric hyperbolic gives the function that evaluates the proximity to 1 of the risk-free rate function: \[ y=\frac{1}{|1-x|} \] While a dummy variable represents the risk-premium rate condition: \[ f(n) = \begin{cases} 1, & \mbox{if } risk premium\mbox{ <5\%} \\ 2, & \mbox{otherwise } \end{cases} \] Finally, the value function can be represented as: \[ g(n) = ln(\frac{1}{|1-x|}*f(n)) \]
library(plotly)
## Loading required package: ggplot2
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
v <- function(dummy, x) {
# value function: given the risk premium rate = 'dummy' and
# 'x' = risk free rate as input return a value which is higher
# when x -> 1 and dummy > 4
for (t in seq_along(dummy)) {
if (dummy[t] > 4) {
dummy[t] <- 2
}
else {
dummy[t] <- 1
}
}
value <- log(abs(1 / (1 - x)) * dummy)
return(value)
}
graphValueFunction <- function(){
risk_prem <- c(seq(2, 6, 0.02))
risk_free <- c(seq(0.01, 2, 0.01))
value <- matrix(0, nrow = 0, ncol = 3)
for (x in risk_prem) {
for(y in risk_free){
value <- rbind(value, c(log(v(x, y)), x, y))
}
}
value[!is.finite(value[, 1]), 1] <- 0
plot_ly(z = value, type = "surface")
}
graphValueFunction()